'use strict';
function compare(arr1,arr2){
    if(arr1<arr2){
      return -1;
    }
    else if(arr1>arr2){
      return 1;
    }
    else{
      return 0;
    }
  }
var calculate_median = function(collection){
    let result;
    let collection_even=[];
    for(let i in collection){
        if(i%2!=0){
            collection_even.push(collection[i])
        }
    }
    collection_even.sort(compare);
    if(collection_even.length%2==0){
        result=(collection_even[collection_even.length/2]+collection_even[collection_even.length/2-1])/2;
     }
     else{
       result=collection_even[(collection_even.length-1)/2];
     }
     console.log(result);
     return result;
}
module.exports = calculate_median;
calculate_median([1, 2, 3, 4, 5, 6, 7, 8, 9]);
